package cn.z2huo.demo.spring.webmvc.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

/**
 * <p>通过该切面，验证 controller 中方法返回了，但是 {@link SseEmitter} 还在返回数据
 *
 * @author z2huo
 */
@Component
@Aspect
@Slf4j
public class SSETestAspect {

    @Pointcut("execution(* cn.z2huo.demo.spring.webmvc.controller.sse.SSETestController.simpleTest*(..))")
    public void pointcut() {
    }

    @After("pointcut()")
    public void after() {
        log.info("sse aspect after");
    }

    @AfterReturning("pointcut()")
    public void afterReturn() {
        log.info("sse aspect after return");
    }

}
